package com.bss.service.impl;

import com.bss.dao.CategoryMapper;
import com.bss.pojo.Category;
import com.bss.pojo.CategoryExample;
import com.bss.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @Author 袁飞
 * @company 中原工学院
 * @create 2020-03-14-19:35
 */
@Service
public class CategoryServiceImpl implements CategoryService {
    @Autowired
    CategoryMapper CategoryMapper;
    public int addCategory(Category Category) {
        return CategoryMapper.insert(Category);
    }

    public int updateCategory(Category Category) {
        return CategoryMapper.updateByPrimaryKeySelective(Category);
    }

    public Category findCategoryById(Integer id) {
        return CategoryMapper.selectByPrimaryKey(id);
    }

    public int deleteCategoryById(Integer id) {
        return CategoryMapper.deleteByPrimaryKey(id);
    }

    public List<Category> findAll() {
        CategoryExample CategoryExample = new CategoryExample();
        CategoryExample.Criteria criteria = CategoryExample.createCriteria();
        return CategoryMapper.selectByExample(CategoryExample);
    }

}
